﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DNA_Analysis.Models;

namespace DNA_Analysis.Controllers
{ 
    public class ResearchDiseaseProbabilityController : Controller
    {
        private DNAAnalysisEntities db = new DNAAnalysisEntities();

        //
        // GET: /ResearchDiseaseProbability/

        public ViewResult Index()
        {
            var researchdiseaseprobability = db.ResearchDiseaseProbability.Include("Disease").Include("Research");
            return View(researchdiseaseprobability.ToList());
        }

        //
        // GET: /ResearchDiseaseProbability/Details/5

        public ViewResult Details(int id)
        {
            ResearchDiseaseProbability researchdiseaseprobability = db.ResearchDiseaseProbability.Single(r => r.Id == id);
            return View(researchdiseaseprobability);
        }

        //
        // GET: /ResearchDiseaseProbability/Create

        public ActionResult Create()
        {
            ViewBag.Disease_Id = new SelectList(db.Disease, "Id", "Name");
            ViewBag.Research_Id = new SelectList(db.Research, "Id", "DNAPartialPattern");
            return View();
        } 

        //
        // POST: /ResearchDiseaseProbability/Create

        [HttpPost]
        public ActionResult Create(ResearchDiseaseProbability researchdiseaseprobability)
        {
            if (ModelState.IsValid)
            {
                db.ResearchDiseaseProbability.AddObject(researchdiseaseprobability);
                db.SaveChanges();
                return RedirectToAction("Index");  
            }

            ViewBag.Disease_Id = new SelectList(db.Disease, "Id", "Name", researchdiseaseprobability.Disease_Id);
            ViewBag.Research_Id = new SelectList(db.Research, "Id", "DNAPartialPattern", researchdiseaseprobability.Research_Id);
            return View(researchdiseaseprobability);
        }
        
        //
        // GET: /ResearchDiseaseProbability/Edit/5
 
        public ActionResult Edit(int id)
        {
            ResearchDiseaseProbability researchdiseaseprobability = db.ResearchDiseaseProbability.Single(r => r.Id == id);
            ViewBag.Disease_Id = new SelectList(db.Disease, "Id", "Name", researchdiseaseprobability.Disease_Id);
            ViewBag.Research_Id = new SelectList(db.Research, "Id", "DNAPartialPattern", researchdiseaseprobability.Research_Id);
            return View(researchdiseaseprobability);
        }

        //
        // POST: /ResearchDiseaseProbability/Edit/5

        [HttpPost]
        public ActionResult Edit(ResearchDiseaseProbability researchdiseaseprobability)
        {
            if (ModelState.IsValid)
            {
                db.ResearchDiseaseProbability.Attach(researchdiseaseprobability);
                db.ObjectStateManager.ChangeObjectState(researchdiseaseprobability, EntityState.Modified);
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            ViewBag.Disease_Id = new SelectList(db.Disease, "Id", "Name", researchdiseaseprobability.Disease_Id);
            ViewBag.Research_Id = new SelectList(db.Research, "Id", "DNAPartialPattern", researchdiseaseprobability.Research_Id);
            return View(researchdiseaseprobability);
        }

        //
        // GET: /ResearchDiseaseProbability/Delete/5
 
        public ActionResult Delete(int id)
        {
            ResearchDiseaseProbability researchdiseaseprobability = db.ResearchDiseaseProbability.Single(r => r.Id == id);
            return View(researchdiseaseprobability);
        }

        //
        // POST: /ResearchDiseaseProbability/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {            
            ResearchDiseaseProbability researchdiseaseprobability = db.ResearchDiseaseProbability.Single(r => r.Id == id);
            db.ResearchDiseaseProbability.DeleteObject(researchdiseaseprobability);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}